Plugin: Unarmored Skill for Everyone
Author: Low Post
Version: 3.0.4
__________________________________________________________________________________________
1. Description
2. Installation / Uninstallation
	2.a.1) Installation
	2.a.2) Update from GalerionTrueUnarmored 2.0.1
	2.a.3) Update from a previous version of Unarmored Skill for Everyone
	2.b) Uninstallation
3. "Technical" information & useful console commands
	3.a) Display of additional Information
	3.b.1) Maximum Defense Bonus
	3.b.2) Comparison chart
	3.b.3) Reducing the Defense Bonus
	3.b.4) Messages about changes of the real Defense Bonus
	3.c) Starting Value of the Unarmored Skill
	3.d) Training of the Unarmored Skill
	3.e) Maximum Skill Level
	3.f) Lights able to be turned on or off
4. Known Bugs & Issues
5. Known Incompatibilities
6. Hosting Information
7. Contact
8. Credits
9. Used Tools & Resources
10. Changelog

	+-----------------------------------------------------------------------------------+
						ATTENTION:				    
		      This is a revision of GalerionTrueUnarmored by Galerion.		    
	  Unfortunately, I wasn't able to make contact with him and the ReadMe doesn't say 
				    anything about such cases.				    
		Therefore, I don't have the permission to release this Plugin.		    
	Although, I don't want to deprive the community of this Plugin. I put this warning 
	 at the top of the ReadMe, so everyone who doesn't want to use a revision released 
			without written permission can forgo this Plugin.		    
	+-----------------------------------------------------------------------------------+

==============
1. Description
==============

This Plugin is an enhancement/revision of GalerionTrueUnarmored 2.0.1:
It adds an "Unarmored skill" to the game.
This causes players to get a defense bonus even without wearing an armor so that magiacians 
who prefer using robes have a chance, too. The defense bonus depends on you current Unarmored 
Skill, but also from the armor you're wearing. Certainly, you only get a bonus for the 
unarmored parts of your body. ;)
Certainly, the unarmored defense bonus will never be the same as the best one you get from 
an armor. You can find a comparison chart under point 3. It's assumed that you get the 
maximum bonus possible (which means you wear no/the complete armor).
Compared to the original version, I changed the following things:
      - I used OBSE-commands for a better imitation of a "real" skill:
		* It's possible to use the unarmored skill as a major skill.
		  You can either replace one of the default major skills, or use it as an 
		  additional major skill.
		* The Unarmored skill now has a governing attribute: agility
		* Skill improvement only if neither heavy, nor light armor has been improved
		  (only when the body, not the armor, was hit)
		* Using a true exponential function
		* Percentual damage to the unarmored-bonus by means of equipped pieces of armor
		* The skill level used by the calculations is influence by luck and fatigue.
      - Including trainer for the Unarmored skill
		* Training the Unarmored skill used Training sessions, just like a normal 
		  skill does.
		* The first trainer lives in Anvil and leaves his home for 2 hours every day 
		  to take a walk.
		* All new dialogs are non-vocal. I suggest to use Universal Silent Voice:
		  	http://www.tesnexus.com/downloads/file.php?id=16622
      - Displaying the skill level
		* X-Skills is used if it has been installed.
		* Otherwise a faction is used.
      - Reducing the time to check wether the player has been hit
		  The time between two updates can be chanded discretionary.
		  Use the following console command:
		  	set LPUSfEGlfDelayTime to x
		  x is the time between two Updates in seconds.
		  	Standard: 0.5 (GalerionTrueUnarmored: 1.0)
      - NPC get the unarmored skill, too (won't be trained)
		That's the main reason I made this Plugin, because I thought it 
		was unfair that only the Player got an unarmored skill. :)
		Because this component causes CTDs for some players you can disable it using 
		the following console command:
		  	set LPUSfEGlbEnableNPC to 0

		  		  	ATTENTION:
		  	This PI REQUIRES OBSE v0018 (or higher)!

================================
2. Installation / Uninstallation
================================

2.a.1) Installation
-------------------
Install OBSE v0018 (or higher).
Copy/Move the 'Unarmored Skill for Everyone.esp' into your '...\Oblivion\Data'-folder and 
activate the *.esp in the OblivionLauncher.
As long as this plugin is active always start Oblivion with the 'obse_loader.exe'.

2.a.2) Update from GalerionTrueUnarmored 2.0.1
----------------------------------------------
Follow the instructions at 2.a.1
Start Oblivion with both, GalerionTrueUnarmored & Unarmored Skill for Everyone activated.
Wait for the MessageBox informing you about the successful update and the Game quitting itself.
Deactivate GalerionTrueUnarmored, start Oblivion & load the automatically created SaveGame.
From now on everything should work like after a normal Installation.

2.a.3) Update from a previous version of Unarmored Skill for Everyone
---------------------------------------------------------------------
Overwrite the old Version with the new one and start the Game.
Wait until the Game quits automatically and use the automatically created SaveGame to continue 
playing. Afterwards, everything should work without any problems.

2.b) Uninstallation
-------------------
For a clean uninstallation, unfortunatly, it isn't enough to just deactivate the plugin. The 
reason is that otherwise the player and all NPCs who've met him will keep the defense-bonus. 
Due to the mass of NPCs it isn't possible to fix this with a simple console command.
Therefore, I included a possibility which should faciliate a clean uninstallation:
Type the following command into your console (` or ~, left next to 1) while this plugin is 
still active:
	set LPUSfEGlbUninstall to 1
After this the defense-bonus will be removed from all NPCs and the player. Additionally, the 
game will be saved (Uninstall Unarmored Skill for Everyone) and closed. Thereafter, you can 
deactivate & delete the *.esp without anything left into your savegame (Certainly you have 
to continue playing with the automatically created SaveGame ;) ).

====================================================
3. "Technical" information & useful console commands
====================================================

3.a) Display of additional Information
--------------------------------------
It's possible to display information about this PI in console. Therfore you have to use 
the following console command:
	set LPUSfEGlibDebug to x
The following values (instead of x) should be interesting for the player:
	1: Displays information about the unarmored skill of the player
	2: Displays information about the unarmored skill of the NPC in the crosshair
	3: Displays information about the player and the NPC in teh crosshair.
	   This way alway the last one updated is displayed.
You have to bear in mind that the last two will use the complete console. This can cause 
Messages of other PIs not to be displayed.
	Note: from now on I'll use for the Debug-Test 1 (2) Player-Debug (NPC-Debug).

3.b.1) Maximum Defense Bonus
----------------------------
The maximum defense bonus is calculated with the following fomulas:
		  	until Skill 25:
Defense Bonus = 0
		     Skill 25 --> Skill 100:
Defense Bonus = 9/2000 * Skill^2
		     Skill 100 --> Skill 200:
Defense Bonus = 13/198000 * Skill^3 - 6487/198000 * Skill^2 + 2714/495 * Skill - 23395/99
		  	ab Skill 200:
Defense Bonus = 500000/3 * Skill^-2 - 8500/3 * Skill^-1 + 85
	ATTENTION: you won't get any defense bonus with a skill below 25

3.b.2) Comparison chart
-----------------------
	 -------------------------------------------------------------------
	| Skill | Unarmored | Fur | Mithril | Glass | Iron | Ebony |Daedric |
	|   20  |     0     |  5  |    12   |   21  |  14  |   25  |   32   |
	|   30  |     4     |  9  |    14   |   23  |  20  |   30  |   34   |
	|   40  |     7     | 10  |    16   |   29  |  22  |   33  |   41   |
	|   50  |    11     | 12  |    20   |   31  |  24  |   40  |   45   |
	|   60  |    16     | 12  |    21   |   33  |  25  |   42  |   52   |
	|   70  |    22     | 13  |    24   |   38  |  30  |   45  |   54   |
	|   80  |    29     | 14  |    24   |   41  |  32  |   50  |   61   |
	|   90  |    36     | 14  |    26   |   43  |  34  |   53  |   64   |
	|   99  |    44     | 14  |    26   |   43  |  34  |   54  |   66   |
	|  100  |    50     | 30  |    48   |   73  |  40  |   60  |   72   |
	|  200  |    75     |  ?  |     ?   |    ?  |   ?  |    ?  |    ?   |
	 -------------------------------------------------------------------

3.b.3) Reducing the Defense Bonus
---------------------------------
However, the value can still be reduced:
      * If you have a skill below 75 and carry more then half of your maximum encumbrance 
	limit (Encumbrance Limit at Player-Debug) your defense bonus will be reduced by x%
	of the maximum defense bonus, where x is how much percent you wear over the 
	(Player-Debug) encumbrance limit.
		  ( ( Encumbrance - EncumbranceLimit ) / EncumbranceLimit )
      * If you have a skill below 50 and wear at leat one piece of armor you won't get any 
	defense bonus
      * If you have a skill below 100 and wear at least one piece of armor your defense bonus 
	will be reduced by 5% of the maximum defense bonus.
      * Additionally, the bonus will be reduced by n%;
	n is the correponding GemeSetting(s) 'iArmorDamageXXChance'

All "DamagePercents" are combined to TotalDamagePercent (at Player-/NPC-Debug).
So, if TotalDamagePercent >= 1 the Defense Bonus will be 0.

3.b.4) Messages about changes of the real Defense Bonus
-------------------------------------------------------
After every change (defense bonus is (not) penalized) per default a Message informing you 
about this incident is displayed. You can disable them using the following console command:
	set LPUSfEGlShowMessages to 0

3.c) Starting Value of the Unarmored Skill
------------------------------------------
The staring value of the unarmored skill will be calculated as followed:
	Every calculation of the start level begins with a value of 5.
	In addition 10% the average of the Acrobatic, Alchemy, Alteration, Athletics, 
	HandToHand, Illusion, Mysticism, Restoration, Security and Sneak skill will be added.
	From this value 10% of the average of the Armorer, Blade, Blunt, Heavy Armor, 
	Light Armor and Marksman skill will be substracted.
	If you chosed Magic as class Specialization the value will be increased by 5.
	Provided that you chose to use the unarmored skill as a major skill this value will 
	be increased by 20.
  If you want to change the skill of the player you can use the following console command:
	set LPUSfEGllPlayerSkill to x

3.d) Training of the Unarmored Skill
------------------------------------
Something about the training of the unarmored skill:
      * Only works for the player
		 NPCs have a constant skill level which is calculated as follows:
		  Primarily, the average of all (Vanilla-)Skills is calculated.
		  To this value 10% of the average of the Acrobatic, Alchemy, Alteration, 
		  Athletics, HandToHand, Illusion, Mysticism, Restoration, Security and 
		  Sneak skill is added.
		  From this value 10% of the average of the Armorer, Blade, Blunt, 
		  Heavy Armor, Light Armor and Marksman skill is subracted.
		  If the NPC has Magic as class Specialization the value is increased by 5.
		 An exception to this rule are the Trainers which a a static skill level 
		  which was specified by me.
      * After the player has been in hurt during combat and neither light, nor heavy armor 
	has been trained the "Progress" will be increased by a certain value.
	You can change this value with the following console command:
		  set LPUSfEGlSkillUseIncrement to x
	The current value is displayed at Player-Debug in the console.
      * After Progress >= SkillNext a level up will follow and Skill Next will be newly 
	calculated (also happens after the calculation of the start skill). The calculation of 
	SkillNext will be the same like the one of a normal skill.

3.e) Maximum Skill Level
------------------------
The maximum Skill level which can be reached is by default 100 (with OBSE_Elys_Uncapper 200, 
if activated in the *.ini). Beyond this there won't be any training. You can change this 
value with the following console command:
	set LPUSfEGllMaximumSkillLevel to x

Using the console command mentioned above to change the skill level of the player it's 
possible to reach a higher skill lever (which also has an effect), but this would be cheating 
and that's just bad manners. ;)

3.f) Lights able to be turned on or off
---------------------------------------
As some of you might have seen in my little Teaser-Video I implemented Lights which are able 
to be turned on or off.
A Light turned on can be turned off simply by activating it, or by using an Frost Damage- or
Resist Fire-Magic Effect.
A Light turned off can be turned on by activating it with an equipped torch, or by using a 
Fire Damage- or Light-Magic Effect.

======================
4. Known Bugs & Issues
======================

 - The Trainers aren't fully integrated into the world of Tamriel, yet.
 - Some Lights keep their flames when they are turned off.
 - If your only equipped armor doesn't use a recognized slot no message is displayed when you 
   unequip that armor.
 - My english isn't the best. ;)

============================
5. Known Incompatibilities
============================

 - nGCD, OXP & other alternative levelling systems
	 Not fully incompatible, so they won't work together in any way. It's just the case 
	  that the Unarmored skill isn't integrated in the new levelling system.
	 To come a bit closer to the Oblivion XP (OXP) levelling system it is advisable to 
	  use the following console command:
		  set LPUSfEGlfSkillUseIncrement to 0
	  It deactivates training through simple being-hit; training with trainers is still 
	  possible.

I plan to create some compatibility based (optional) adjustment to the plugins mentioned 
above (nGCD & OXP). When they are created depends on how much time I have and 
how much time is required to create these adjustments.

======================
6. Hosting Information
======================

Due to this Plugin being a Open Beta-Version I expect more frequent Updates then a normal 
Plugin. Therefore, I do NOT allow to upload this Plugin anywhere else.
Once I declare the beta phase as finished the rules I specified for my other plugins apply to 
this one as well. Once things have progressed to that point, I'll specify them here, too.


If I left Oblivion-Modding someday and you want to do something else then hosting* this Plugin 
ask for a permission, first. ;)
If you can't get in contact with me (which means: no reply in a month or more using every 
way to contact me mentioned below) you can do whatever you was, as long as you give 
proper credits.


*If you can't get in contact with me and the Plugin isn't available anymore, you're also 
allowed to upload it on your site. ;)

==========
7. Contact
==========

You can contact me (Low Post) via Private Message in one of the following forums 
or by sending me a mail.

Mail address
	<spamviech@web.de>

Official ES forum
	http://www.bethsoft.com/bgsforums/

Multimediaxis
	http://www.multimediaxis.net/index.php
ElderScrollsGames.de
	http://www.elderscrollsgames.de/distribution/
Newraven.net
	http://forum.newraven.net/
World of Elder Scrolls
	http://forum.worldofplayers.de/forum/index.php
Scharesoft forum
	http://www.scharesoft.de/joomla/forum/index.php

==========
8. Credits
==========

Galerion for his "primal version" of this Plugin.

The OBSE-Team for the creation of OBSE and for realising a lot of my requests.
You all are just great. Keep up the good work. :)

Elys for creating Pluggy.

The guys from the CS-Wiki, who provide to (almost) every Script command a detailed Description.

haama because he explained to me how the thing with the Update works.

DWS, because he put my nose on the solution for the Slowdown with DarkUI'd DarN.
Who would think that a Return in the Gamemode-Block helps against Slowdons in Menumode?

Laulajatar, because he created the Icons and found another reason for the Slowdown with 
DarkUI'd DarN. Why causes a Variable as a float, but not as a long such problems when used 
with ModActorValue?
And why was it a float at all? :p

Satsuma, because he created Fenas Erelie's hut and everything around it.

Puff for creating the invisible collision mesh I used for the Lights which are able to be 
turned on or off.

Everyone who spends time writing tutorials.

Everyone who deserves it, but I forgot to mention. ;)

=========================
9. Used Tools & Resources
=========================

TES Construction Set:
	 http://theelderscrolls.info/?go=dlfile&fileid=158

Oblivion Script Extender:
	 http://www.obse.silverlock.org/

Pluggy:
	 http://karamail.nerim.net/elys/Pluggy/

Wrye Bash:
	 http://wrye.ufrealms.net/#WryeBash

Oblivion Mod Manager:
	 http://timeslip.chorrol.com/obmm_download.html

Name Generator:
	 http://www.silgrad.com/oblivion/rangen/index.html
	 http://www.meisterdermagie.de/ngen/ngen.html

Invisible Activator modders resource:
	 http://tesnexus.com/downloads/file.php?id=22549

=============
10. Changelog
=============

3.0.4:	- Fixed a Bug in the OBSE-Version-Check.
	- No Skill-Reset with the Update-Save.

3.0.3:	- Fixed a Bug with the German SkillBook not working.
	- Fixed a Bug with Training-Conditions.
	- Fixed another source for a Menu-Slowdown with DarNified UI which didn't have any 
	  effect before. Now the Inventory is only forced to update when sth. has changed.
	- Generated PathGrids in the Worldspace around the Master trainer.

3.0.2:	- Increasing the required OBSE-Version to v0018
	- Removed dependency on Pluggy.
	- Fixed a Bug in Magic Effect-Scripts.
	- Fixed a Bug in Rename-Scripts.
	- Improved Formula for Calculation the NPC-Skill-Level.
	- Implemented the Quest for the Master Trainer.
	- Implemented ModPCMiscStat to show Skill Increases, Training Sessions and 
	  Read Skill Books (yes, I also implemented one) for the Unarmored Skill on the 
	  Players Statistics Page.
	- Optionally implemented Custom Spell Icons.
	- Optionally implemented X-Skills.
	- Added support for "Unarmored Base.esm".
	- Added support for "GlobalSettingsInterface.esm".

2.4.0:	- Fixed the last bit of incompatibility with DarkUI'd DarN (now for real).
	- Included Icons (Thanks to Laulajatar).
	- Faluel Donail, Akish & Fenas Erelie integrated into the world.
		  * Currently without any schedule, they just stand there and do nothing.
		  * The quest for the master trainer hasn't been implemented, too.
		    Currently you can train with him without any quest.

2.3.1:	- Fixed the last bit of incompatibility with DarkUI'd DarN.
	- Fixed a Bug which caused the Game to terminate without saving while deinstallation.

2.3.0:	- If the defense bonus was penalized because of too much weight, but not longer 
	  affected bye wearing some pieces of armor the wrong messages has been displayed.
	- Some little Tweaks in Sukchuk Dirr`tur's concealment
	- Fixed a Bug which disabled Training in the english Version.
	- Implemented the possibility to disable the Messages informing about a penalized 
	  defense bonus:
		  set LPUSfEGlShowMessages to 0
	- Implemented the possibility to disable the NPC-Component of this Plugin:
		  set LPUSFEGlEnableNPC to 0
	- Created compatibility to DarkUI'd DarN (hopefully).

2.2.2:	- Fixed the Calculation of TotalDamagePercent
	  Thanks to Scoopy for finding this Bug. :)

2.2.1:	- Error Messages for Armor are only displayed if the only Slot they use doesn't have 
	  an "iArmorDamageXXChance"-GameSetting.
		   In Addition the Name & ID of the Actor wearing it is displayed, too.
	- Moving on to OBSE-Strings. Nevertheless, Pluggy is still required.
	  (LC, GetFileSize, INIReadInt, Arrays)

2.2.0:	- Reduced Spam in Console produced by a massive usage of GetGameSetting.
	- Implemented Timer in Menumode, too.
	- Introduced Spells & Scroll to absorb/drain/fortify the unarmored skill.
	- Implemented Influence on the Skill by Luck & Fatigue.
	- Every Trainer now has a name :)
	- Changed the damage system a bit.

2.1.1:	- Fixed some Minor Bugs

2.1.0:	- Trainer for the Unarmored skill
	- Changing the calculation of the PlayerStartSkill

2.0.0:	- Increasing the required OBSE-Version to v0016
	- Implement a German Version
	  (Is determinded by the file size of the Oblivion.esm)
	  Changing possible with this console command:
		  	set LPUSfEGlQuest.Language to 0/1	;English/German
	-Additional approaches to a real skill:
		  * Affection the attibute bonus for Agility on LevelUp
		  * Possibility to use the Unarmored skill as a major skill, either replacing 
		    a normal major skill, or as an additional major skill. 
		    Affecting the LevelUp count.
		  * Changing the calculation of the PlayerStartSkill
		    --> Increased similarity to vanilla-skills
		  	retained calculation for NPCs
		    --> otherwise, skill would be too low
	- Improved the method for checking equipped pieces of armor

1.0.2:	- Fixed a Bug which caused players without a specialization in magic to become a 
	  master of the unarmored skill with the first strike on an unarmored part of the body.
	- Fixed a Bug which caused an uncloseable MessageBox to appear when someone equipped a 
	  piece of Armor using an unusual Slot

1.0:	- Initial Release (Open Beta)